package com.nantian.logic.utils;

/**
 * Created by AileYoung on 2017/10/27.
 * 通用返回结果
 * @param <T>
 */
public class UniversalResult<T> {
    public static final int SUCCESS = 200;// 业务处理成功

    public static final int GETNULL = 300;// 查询到空值

    public static final int FAILURE = 400;// 业务处理失败

    public static final int SERVER_ERROR = 500;// 内部出错

    public static final int UNLOGIN = 1000;// 鉴权失败,需要登录

    public static final int DANGER_CHAR = 1001;// 存在危险字符

    public static final int PARAM_VALIDATE_FAILED = 2000;// 参数校验失败

    public static final int PARAM_ERROR = 2001;// 参数错误

    public static final int CHECK_ERROR = 4000;// 验证失败


    private int code = 0;

    private String msg = "";

    private T data = null;

    public UniversalResult() {
    }

    public UniversalResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public UniversalResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String toString(){
        return "{\"code\":\""+this.code+
                "\",\"msg\":\""+this.msg+
                "\",data:\""+this.data+"\"}";
    }
}
